package com.smh.mianshi.processor;

import com.smh.mianshi.domain.po.Teacher;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.stereotype.Component;

/**
 * @author shiminghui
 * @date 2024/9/27 20:47
 * @description: TODO
 */
@Component
public class MyPostProcessor implements BeanFactoryPostProcessor {
    //在bean工厂初始化之后调用的回调函数,用于的创建beanDefinition
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {

        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(Teacher.class);

        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) configurableListableBeanFactory;

        beanFactory.registerBeanDefinition("teacher", beanDefinition);


    }
}
